package com.zzxy.spring.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.io.ObjectOutput;

/**
 * @author aven
 * @description: TODO
 */

public class MyAspect3 {
    public void myBefore(JoinPoint joinPoint) {
        System.out.println(joinPoint.getSignature().getName());
        System.out.println("before");
    }

    public void myAfterReturning(JoinPoint joinPoint, Object ret) {
        System.out.println(joinPoint.getSignature().getName());
        System.out.println("after returning  : " + ret);
    }

    public Object myAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println(proceedingJoinPoint.getSignature().getName());
        System.out.println("start trans ...");
        Object obj = proceedingJoinPoint.proceed();
        System.out.println("stop trans ...");
        return obj;
    }

    public void myAfterThrowing(JoinPoint joinPoint, Throwable throwable) {
        System.out.println("throwable : " + throwable.getMessage());
    }

    public void myAfter() {
        System.out.println("after..");
    }
}
